## Makefile for the doc subdirectory of GNU libtextstyle.
## Copyright (C) 2009, 2011, 2014, 2017-2019 Free Software Foundation, Inc.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <https://www.gnu.org/licenses/>.

## Process this file with automake to produce Makefile.in.

AUTOMAKE_OPTIONS = 1.13 gnits
EXTRA_DIST =
MOSTLYCLEANFILES =

# List of -I options referring to directories that contain texinfo sources
# used by this directory.
# Should contain at least one -I option, to work around a bug in texi2dvi 1.13,
# see <https://lists.gnu.org/archive/html/bug-automake/2009-04/msg00029.html>.
TEXINCLUDES = -I .

MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
MAKEINFOFLAGS = $(TEXINCLUDES) --no-split

info_TEXINFOS = libtextstyle.texi
# List of texinfo sources @included by libtextstyle.texi, excluding version.texi.
libtextstyle_TEXINFOS = gpl.texi fdl.texi

# The dependencies of stamp-vti generated by automake are incomplete.
# So we have to duplicate the entire rule which would otherwise be generated
# by automake.
$(srcdir)/stamp-vti: $(info_TEXINFOS) $(libtextstyle_TEXINFOS) $(top_srcdir)/version.sh
	(set `$(SHELL) $(top_srcdir)/build-aux/mdate-sh $(srcdir)/libtextstyle.texi`; \
	echo "@set UPDATED $$1 $$2 $$3"; \
	echo "@set UPDATED-MONTH $$2 $$3"; \
	echo "@set EDITION $(VERSION)"; \
	echo "@set VERSION $(VERSION)") > vti.tmp
	cmp -s vti.tmp $(srcdir)/version.texi \
	  || (echo "Updating $(srcdir)/version.texi"; \
	      cp vti.tmp $(srcdir)/version.texi)
	rm -f vti.tmp
	cp $(srcdir)/version.texi $@

# We distribute only the split HTML documentation.
# The user can generate the others, via
#   make libtextstyle.ps
#   make libtextstyle.pdf
#   make libtextstyle.html

all-local: html-local
install-data-local: install-html
installdirs-local: installdirs-html
uninstall-local: uninstall-html
dist-hook: dist-html

html-local: html-split
# Override of automake's definition. The HTML files we want to distribute are
# not the ones that automake knows about, and we cannot define HTMLS to a value
# containing wildcards.
install-html: install-html-split
	@:
uninstall-html: uninstall-html-split
dist-html: dist-html-split

# CLEANFILES: libtextstyle.{dvi,ps,pdf,html} are already known to automake.
MAINTAINERCLEANFILES = libtextstyle_*.html


# Documentation in DVI format.

# Override of automake's definition:
#TEXI2DVI = @TEXI2DVI@
TEXI2DVI = @TEXI2DVI@ $(TEXINCLUDES)

# The install-dvi target is already defined by automake.

installdirs-dvi:
	$(MKDIR_P) $(DESTDIR)$(dvidir)

uninstall-dvi:
	$(RM) $(DESTDIR)$(dvidir)/libtextstyle.dvi


# Documentation in Postscript format.

# Override of automake's definition:
#DVIPS = @DVIPS@
DVIPS = @DVIPS@ -D600

libtextstyle.ps: libtextstyle.dvi
	$(DVIPS) -o $@ `if test -f libtextstyle.dvi; then echo libtextstyle.dvi; else echo $(srcdir)/libtextstyle.dvi; fi`

# The install-ps target is already defined by automake.

installdirs-ps:
	$(MKDIR_P) $(DESTDIR)$(psdir)

uninstall-ps:
	$(RM) $(DESTDIR)$(psdir)/libtextstyle.ps


# Documentation in Portable Document Format.

# Override of automake's definition:
#TEXI2PDF = @TEXI2DVI@ --pdf
TEXI2PDF = @TEXI2DVI@ --pdf $(TEXINCLUDES)

# The install-pdf target is already defined by automake.

installdirs-pdf:
	$(MKDIR_P) $(DESTDIR)$(pdfdir)

uninstall-pdf:
	$(RM) $(DESTDIR)$(pdfdir)/libtextstyle.pdf


# Documentation in HTML format.

TEXI2HTML = @PERL@ $(top_srcdir)/build-aux/texi2html

html-monolithic: libtextstyle.html
html-split: libtextstyle_toc.html

# Override of automake's definition.
# We want to use texi2html, not makeinfo --html.
libtextstyle.html: libtextstyle.texi version.texi $(libtextstyle_TEXINFOS)
	$(TEXI2HTML) $(TEXINCLUDES) -no-sec-nav -no-menu -toc-links -number -monolithic $(srcdir)/libtextstyle.texi

libtextstyle_toc.html: libtextstyle.texi version.texi $(libtextstyle_TEXINFOS)
	case "@PERL@" in \
	  *"/missing perl") \
	     $(TEXI2HTML) $(TEXINCLUDES) -no-sec-nav -no-menu -toc-links -number -split_chapter $(srcdir)/libtextstyle.texi || exit 0 ;; \
	  *) $(RM) libtextstyle_*.html ; \
	     $(TEXI2HTML) $(TEXINCLUDES) -no-sec-nav -no-menu -toc-links -number -split_chapter $(srcdir)/libtextstyle.texi ;; \
	esac \
	&& { mv libtextstyle/libtextstyle.html libtextstyle_toc.html; \
	     for file in libtextstyle/*.html; do \
	       sed -e 's/libtextstyle\.html/libtextstyle_toc.html/g' < $$file > `basename $$file` && rm -f $$file; \
	     done; \
	     rmdir libtextstyle; \
	   }

install-html-monolithic: libtextstyle.html
	$(MKDIR_P) $(DESTDIR)$(htmldir)
	$(INSTALL_DATA) `if test -f libtextstyle.html; then echo .; else echo $(srcdir); fi`/libtextstyle.html $(DESTDIR)$(htmldir)/libtextstyle.html

install-html-split: libtextstyle_toc.html
	$(MKDIR_P) $(DESTDIR)$(htmldir)
	for file in `if test -f libtextstyle_toc.html; then echo .; else echo $(srcdir); fi`/libtextstyle_*.html; do \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(htmldir)/`basename $$file`; \
	done

installdirs-html:
	$(MKDIR_P) $(DESTDIR)$(htmldir)

uninstall-html-monolithic:
	$(RM) $(DESTDIR)$(htmldir)/libtextstyle.html

uninstall-html-split:
	$(RM) $(DESTDIR)$(htmldir)/libtextstyle_*.html

dist-html-monolithic:
	$(MKDIR_P) $(distdir)/
	file=libtextstyle.html; \
	if test -f $$file; then d=.; else d=$(srcdir); fi; \
	cp -p $$d/$$file $(distdir)/$$file || exit 1

# We would like to put libtextstyle_*.html into EXTRA_DIST, but it doesn't work.
dist-html-split: libtextstyle_toc.html
	$(MKDIR_P) $(distdir)/
	file=libtextstyle_toc.html; \
	if test -f $$file; then d=.; else d=$(srcdir); fi; \
	for file in `cd $$d && echo libtextstyle_*.html`; do \
	  cp -p $$d/$$file $(distdir)/$$file || exit 1; \
	done
